##############################################################
#Figure 4: Proximity to Hurricanes $\downarrow$ Democrat Vote Share in U.S. House
##############################################################

hou.prec <- read.dta13("./temp/fig4adata.dta")

newdf <- hou.prec %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)

g<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="grey60", size=1.2, lwd=1.2, fatten=2, fill="goldenrod1", shape=21) +
  ylim(-.2,.05) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Democrat Share U.S. House") +
  geom_hline(yintercept=0, col="grey60", lwd=1, lty="dashed", alpha=.6)  + 
  ggtitle("Wind >64kt") + theme(plot.title = element_text(hjust = .5, face="bold", size=15, colour = "grey60"), axis.text=element_text(size=12),
                                axis.title= element_text(size=15))
g

rm(newdf, hou.prec)
hou.prec.major <- read.dta13("./temp/fig4bdata.dta")


newdf <- hou.prec.major %>% 
  gather(variable, value, -var)%>%
  spread(var, value)

newdf$id <- c(5,4,3,2,6,1)

g2<- ggplot() + 
  geom_pointrange(data=newdf, mapping=aes(x=id, y=coef, ymin=ci_upper, 
                                          ymax=ci_lower), color="grey60", size=1.2, lwd=1.2, fatten=2, fill="goldenrod1", shape=21) +
  ylim(-.2,.05) +
  scale_x_discrete(limit=c("1", "2", "3", "4", "5", "6"), labels= c("[500,30)", "[400,30)", "[300,30)", "[200,30)", "[100,30)", "[50,30)")) + 
  xlab("Distance Band")  + ylab("Estimate on Democrat Share U.S. House") +
  ggtitle("Wind >96kt") + theme(plot.title = element_text(hjust = .5, face="bold", size=15, colour = "grey60"), axis.text=element_text(size=12),
                                axis.title= element_text(size=15)) + 
  geom_hline(yintercept=0, col="grey60", lwd=1, lty="dashed", alpha=.6)  
g2

library(ggpubr)
ggarrange(g,g2)
ggsave(file="./figures/fig4.pdf")


